package cn.woflcode.game.model;

import cn.woflcode.game.Global.Global;
import cn.woflcode.game.Global.ImageUtil;

import java.awt.*;
import java.awt.image.BufferedImage;

public class EnemyBullet {
    //--------------------------状态---------------
    //位置:x坐标
    private int x;
    //位置:y坐标
    private int y;
    //大小:宽
    private int width;
    //大小:高
    private int height;
    //飞机的图片
    private BufferedImage image = ImageUtil.getImage("enemy_small_bullet");
    //子弹速度
    private int spead=8;
    //状态
    private Global.FlyObjectState state = Global.FlyObjectState.ALIVE;
    //----------------------构造器-----------------
    public EnemyBullet(int x,int y){
        this.width=image.getWidth();
        this.height=image.getHeight();
        this.x=x-8;
        this.y=y;
    }
    //---------------------功能------------------
    //画自己
    public void drawSelf(Graphics g){
        g.drawImage(image,x,y,null);
    }
    //移动
    public void  move(){
        this.y+=spead;
    }
    //判断是否越界
    public boolean outOfBound(){
        return this.y>= Global.GAME_UI_HEIGHT;
    }
    //获取小战机子弹外围的圆形的圆心（x,y）和半径
    //圆 x坐标
    public int getCenterX(){
        return x+width;
    }
    //圆y坐标
    public int getCenterY(){
        return y+height-Math.min(width,height);
    }
    //圆半径
    public int getR(){
        return Math.min(width,height)/2;
    }
    public Global.FlyObjectState getState() {
        return state;
    }
    public void setState(Global.FlyObjectState state) {
        this.state = state;
    }
}
